package com.Telien.app.ui.main;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import com.Telien.app.request.service.RequestService;
import com.Telien.app.user.object.User;

public class SearchRide extends JPanel implements ActionListener {
	private User user;
	private RequestService requestService;
	
	JLabel lblStart = new JLabel("Start Point");
	JLabel lblEnd = new JLabel("End Point");
	JTextField startField = new JTextField();
	JTextField endField = new JTextField();
	JButton searchBtn = new JButton("Search");
	
	public SearchRide(User usr) {
		user = usr;
		this.initialize();
	}
	
	private void initialize() {
		setSize(600, 500);
		setLayout(null);
		
		lblStart.setBounds(10, 55, 95, 25);
		add(lblStart);
		
		lblEnd.setBounds(10, 105, 95, 25);
		add(lblEnd);
		
		startField.setBounds(110, 55, 200, 25);
		add(startField);
		
		endField.setBounds(110, 105, 200, 25);
		add(endField);
		
		searchBtn.addActionListener(this);
		searchBtn.setBounds(10, 155, 150, 25);
		add(searchBtn);
		
		setVisible(true);
	}
	
	public void actionPerformed(ActionEvent e) {
		String name = e.getActionCommand();
		if (name.equals("Search")) {
			search();
		}
	}
	
	private void search() {
		String start = startField.getText();
		String end = endField.getText();
		System.out.println(start + ":" + end);
		//TODO
	}



}
